package biz

import "context"

type ProductUseCase struct {
	repo ProductRepo
}

func NewProductUseCase(repo ProductRepo) *ProductUseCase {
	return &ProductUseCase{
		repo: repo,
	}
}

type Product struct {
	Id   int64
	Name string
	Num  int64
}

type ProductRepo interface {
	CreateProduct(ctx context.Context, product *Product) (*Product, error)
	GetProduct(ctx context.Context, id int64) (*Product, error)
	UpdateProduct(ctx context.Context, product *Product) (*Product, error)
	DeleteProduct(ctx context.Context, id int64) error
	ListProduct(ctx context.Context, pageNum int64, pageSize int64) ([]*Product, error)
}

func (p *ProductUseCase) CreateProduct(ctx context.Context, product *Product) (*Product, error) {
	return p.repo.CreateProduct(ctx, product)
}

func (p *ProductUseCase) GetProduct(ctx context.Context, id int64) (*Product, error) {
	return p.repo.GetProduct(ctx, id)
}

func (p *ProductUseCase) UpdateProduct(ctx context.Context, product *Product) (*Product, error) {
	return p.repo.UpdateProduct(ctx, product)
}

func (p *ProductUseCase) DeleteProduct(ctx context.Context, id int64) error {
	return p.repo.DeleteProduct(ctx, id)
}

func (p *ProductUseCase) ListProduct(ctx context.Context, pageNum int64, pageSize int64) ([]*Product, error) {
	return p.repo.ListProduct(ctx, pageNum, pageSize)
}
